<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 三个数的最大乘积 -->
    <script>
      var maximumProduct = function (nums) {
        //将数组的值赋值给变量len
        let len = nums.length
        //判断len是否等于3 如果等于就返回nums数组
        if (len === 3) {
          return nums[0] * nums[1] * nums[2]
        }
        //将数组进行排序
        nums.sort((a, b) => a - b)
        //返回三个数的最大乘积
        return Math.max(nums[0] * nums[1] * nums[len - 1], nums[len - 3] * nums[len - 2] * nums[len - 1])
      }
      console.log(maximumProduct([1, 2, 3]))
    </script>
  </body>
</html>
